<% content_for :title do %>
  <%=h @artist.name %>
<% end %>

<% content_for :edit do %>
  <%= link_to 'Delete Entry?', 
              new_delete_request_path(:editable_id => @artist.id, 
                                      :editable_type => "Artist") %> |

  <% if session[:edit_mode] == false %>
    <%= link_to 'Edit This Page', edit_artist_path %> 
  <% else %>
    <%= link_to 'Finish Editing', artist_path %> 
  <% end %>
<% end %>

<div id="errors">
  <%= error_messages_for(:artist) %>
</div><!-- /errors -->

<table id="entry-table">

  <tr id="entry-table-row1">

    <td id="entry-top-pane">
      <span class="entry-title">
        <%=h @artist.name %>
      </span>

      <div id="top-tools">
        <% if @favorite.nil? %>
          <% if permitted_to? :create, :favorites %>
            <%= link_to 'Favorite', add_favorite_path(:id => @artist.id,
                                                      :type => 'Artist') %>
          <% end %>
        <% else %>
          <% if permitted_to? :destroy, :favorites %>
            <%= link_to 'Remove From Favorites', remove_favorite_path(:id => @favorite) %>
          <% end %>
        <% end %>
      </div><!-- /top-tools -->

    </td>
  </tr><!-- /entry-table-row1 -->
  
  <tr id="entry-table-row2">

    <td class="entry-left-pane">

      <div id="entry-left-image">
        <%= render :partial => 'images/image_viewer',
                   :locals => {:item => @artist,
                               :gallery_path => artist_images_path(@artist) } %>
      </div><!-- /entry-left-image -->

	  <a href="#image-upload" class="lightwindow">Upload Image</a>
	  
      <div id="image-upload" style="display: none">
        <br />
        <% form_for @artist, :html => {:multipart => true} do |form| %>

          <% fields_for :images do |image_form| %>
			<p>
            Image Upload: <%= image_form.file_field :image %><br />
            Type: <%= image_form.select :image_type, [ ['Photo'],
                                                       ['Logo'],
                                                       ['Cover'] ] %>
            <br />
            Description: <%= image_form.text_field :description %>
			</p>
          <% end %>

          <%= form.submit "Upload Image" %>
        <% end %>
      </div><!-- /image-upload -->

    </td><!-- /entry-left-pane -->
	
    <td class="entry-mid-pane">
	
      <table id="entry-mid-info">
        <% form_for @artist do |artist_form| %>
        
          <tr>
            <td class="entry-info-label">Name:</td>
            <td><%= artist_form.text_field :name %></td>
          </tr>

        <% if @artist.is_group == false %>
          <tr>
            <td class="entry-info-label">Birth Name:</td>
            <td><%= artist_form.text_field :proper_name %></td>
          </tr>
     
          <tr>
            <td class="entry-info-label">Gender:</td>
            <td><%= artist_form.select :gender, [ ["Male"], ["Female"] ] %></td>
          </tr>
        <% end %>

        <tr>
          <td class="entry-info-label">Hometown:</td>
          <td><%= artist_form.text_field :city_name, :value => @artist.city %></td>
        </tr>

		<tr>
		  <td class="entry-info-label">State:</td>
		  <td><%= artist_form.text_field :state_name, :value => @artist.state %></td>
		</tr>
		
        <tr>
          <td class="entry-info-label">Country:</td>
          <td><%= artist_form.text_field :country_name, :value =>  @artist.country %></td>
        </tr>
		
        <tr>
          <td></td>
          <td>
            <p><%= artist_form.submit "Apply Changes" %></p>
          </td>
        </tr>      

      <% end %>
	  
	    <tr>
            <td class="entry-info-label">Genre:</td>
            <td>
              <%= render :partial => 'genres/list_genres',
                         :locals => {:entry => @artist } %>
            </td>
        </tr>
	  
	  	<tr>
			<td class="entry-info-label">Aliases:</td>
			<td>
			  <%= render :partial => "aliases", :locals => {:artist => @artist } %>
			</td>
        </tr>

        <tr>
			<td class="entry-info-label">Dates:</td>
			<td>
			  <div id="artist-dates">
				<%= render :partial => 'dates/dates',
						   :locals => { :dates => @artist.ordered_dates,
										:item => @artist,
										:dates_url => artist_dates_url,
										:events => ArtistDate::DATE_EVENTS } %>
			  </div>
			</td>
        </tr>
	  
      </table><!-- /entry-mid-info -->
	
    </tr>

    <td class="entry-left-pane">
      <div id="entry-left-menu">
        <ul class="tabnav">
          <%= artist_tab('Bio', 'bio-pane', 'active') %>
          <%= artist_tab('Releases', 'discog-pane', 'inactive') %>
          <%= artist_tab('Songs', 'song-pane', 'inactive') %>
          <%= artist_tab('Discuss', 'forum-pane', 'inactive') %>
          <% if @artist.is_group == true %>
            <%= artist_tab('Members', 'bands-members-pane', 'inactive') %>
          <% else %>
            <%= artist_tab('Bands', 'bands-members-pane', 'inactive') %>
          <% end %>
          <%= artist_tab('Reviews', 'review-pane', 'inactive') %>
        </ul>
      </div><!-- /entry-left-menu -->
    </td>

    <td class="entry-mid-pane">
      <div id="entry-mid-content">

        <div id="bio-pane">
          <h2>Biography</h2>
          <% form_for @artist do |form| %>
            <%= form.text_area :bio, :rows => 20, :cols => 70 %><br />
            <%= form.submit "Update Bio" %>
          <% end %>
        </div><!-- /bio-pane -->

        <div id="discog-pane" style="display: none">

          <h2>Releases</h2>

          <div id="discog-nav">
		    <%= link_to "Add Release", new_release_path(:a_id => @artist.id),
                                         :class => 'lightwindow',
										 :params => 'lightwindow_type=page,lightwindow_width=500,lightwindow_height=500' %>
			<br /><br />
			
            Sort By:
            <% @artist.release_types.each do |type| %>
              <%= link_to_remote type.to_s, :url => release_set_artist_path(@artist, :type => type.to_s),
											:method => :get,
                                            :update => 'discog-results',
                                            :loading => "Element.hide('releases'), Element.show('progress_indicator')",
                                            :loaded => "Element.show('releases')" %>
              
              <%= (type != @artist.release_types.last)? ' | ' : ' ' %>
              
            <% end %>
          </div><!-- /discog-nav -->

          <div id="discog-results">
            <%= render :partial => 'release', :locals => { :category => "All", :releases => @artist.releases } %>
          </div><!-- /discog-results -->

        </div><!-- /discog-pane -->

        <div id="song-pane" style="display: none">
          <h2>Songs</h2>
          <%= link_to 'New Song', new_song_path(:artist_id => @artist.id),
                                  :class => 'lightwindow',
                                  :params => 'lightwindow_type=page,lightwindow_width=500,lightwindow_height=500' %>
		  <br /><br />
          <% if @artist.songs.empty? %>
            There are no songs for this artist.
          <% else %>
            <%= render :partial => 'songs/list_songs',
                       :locals => { :songs => @artist.songs } %>
          <% end %>
        </div><!-- /song-pane -->

        <div id="forum-pane" style="display: none">
          <h2><%=h @artist.forum.title %></h2>
          <%= render :partial => "forums/forum", :locals => {:forum => @artist.forum } %>
        </div><!-- /forum-pane -->

        <div id="bands-members-pane" style="display: none">
          <%- if @artist.is_group == true -%>
            <h2>Members</h2>
            <%= render :partial => "edit_members", :locals => {:artist => @artist} %>
          <%- else -%>
            <h2>Bands</h2>
            <%= render :partial => "edit_bands", :locals => {:artist => @artist} %>
          <%- end -%>
        </div><!-- /bands-members-pane -->

        <div id="review-pane" style="display: none">
          <h2>Reviews</h2>
          <%= render :partial => 'reviews/review', :locals => {:item => @artist} %>
        </div><!-- /review-pane -->

      </div><!-- /entry-mid-content -->
    </td>
  </tr>
</table>
